﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Text;
using LManager;
using Skin;
using System.Windows.Forms;

namespace Before_setting
{
    
    public class Before_Class
    {
        public static string current;
        public bool Enabled { get; set; }
        public Before_Class()
        {            
            string path = System.Windows.Forms.Application.ExecutablePath;
            current = path.Substring(0, path.LastIndexOf(@"\"));
            try
            {
                SettingManager.Setting_Class.MainSettings = XDocument.Load(current + @"\Config\general.xml");
                Enabled = true;
            }
            catch
            {
                MessageBox.Show("It is impossible to load setting file!");
                Enabled = false;
                return;
            }
            try
            {
                LanguageManager.Document = XDocument.Load(current + "\\Languages\\" + SettingManager.Setting_Class.GetSettings("Language"));
                Enabled = true;
            }
            catch
            {
                MessageBox.Show("It is impossible to load language file!");
                Enabled = false;
                return;
            }
            try
            {
                SkinManager.path = current + "\\Skins\\" + SettingManager.Setting_Class.GetSettings("SettingsFile");
                SkinManager.folder = current + "\\Skins\\" + SettingManager.Setting_Class.GetSettings("SettingsFile").Split('\\').First() + @"\";
                SkinManager.doc = XDocument.Load(current + "\\Skins\\" + SettingManager.Setting_Class.GetSettings("SettingsFile"));
                Enabled = true;
            }
            catch
            {
                MessageBox.Show("It is impossible to load skin file!");
                Enabled = false;
                return;
            }


        }
    }
}
